﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Seller
{
    public partial class wfForumList : msBsc.Cls.BPDealer
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void getForumList()
        {
            string pIndex = this.GetParamHtValue("pIndex");
            string pRows = this.GetParamHtValue("pRows");
            using (msBsc.AppLogic.DataAlc.CBizSourcePosts sourcePosts=new AppLogic.DataAlc.CBizSourcePosts())
            {
                int pageIndex = 1;
                int pageRows = 11;
                int.TryParse(pIndex, out pageIndex);
                int.TryParse(pRows, out pageRows);
                DataSet ds = sourcePosts.GetVehicleForPageview(pageRows, pageIndex, "");
                if (ds==null||ds.Tables[0].Rows.Count<1)
                {
                    return;
                }
                string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                this.ExecJScript(@"
                            var _html = $('#svc_list_temp').html();

                            laytpl(_html).render(" + retJson + @", function (render) {
                                $('#forumInfo').html(render);
                            });jsPage('divPage', " + Convert.ToInt32(ds.Tables[0].Rows[0]["ROWSCOUNT"].ToString()) + ", " + pageRows + ", " + pageIndex + ", 'goPage');");
            }
        }

        private void getNoticeList() {
            //using (resource)
            //{
                DataSet ds = null;
                //if (ds==null||ds.Tables[0].Rows.Count<1)
                //{
                //    return;
                //}

                string ret = @"[{""Id"":""123"",""NewsTitle"":""地接客公告""},{""Id"":""1234"",""NewsTitle"":""地接客改版""}]";
                //string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                this.ExecJScript(@"GetMarList(" + ret + ");GetMarList()");
            //}
        }

        public override void DoAction()
        {
            if (this.strAction=="init")
            {
                getForumList();
                getNoticeList();
            }
            if (this.strAction=="gopage")
            {
                getForumList();
            }
        }
    }
}